<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <link rel="stylesheet" href="../../css/animate.css">
  <link rel="stylesheet" href="../../iconfont/iconfont.css">
  <link rel="stylesheet" href="../../css/mescroll.css">
  <link rel="stylesheet" href="../../css/gloab.css">
  <title>升级站长</title>
</head>
<body>
  <div id="app">
    <div id="public-header" style="padding-bottom:1.5rem;">
      <div id="statusbar"></div>
      <header class="public-header">
        <div class="public-header-lf iconfont icon-fanhui" @click="javascript:api.closeWin();"></div>
        <div class="public-header-title">升级站长</div>
      </header>
    </div>
    <div class="vip-one" style="margin-top:-1.5rem;">
      <div class="vip-one-top flex auto">
        <div class="vip-one-top-lf F3">
          <span class="personal-header-vip2" style="font-size:0.36rem;">站长权益</span>&nbsp;
        </div>
      </div>
      <div class="vip-one-top" v-html="content" style="font-size: 14px;">

      </div>
      <!-- <p style="color:#888;font-size:0.28rem;" class="auto"><span class="public-dian"></span>&nbsp;可以最多拿到3代提成。</p>
      <p style="color:#888;font-size:0.28rem;" class="auto"><span class="public-dian"></span>&nbsp;赠送5个首页轮播广告位（你及你团队下的人均
可看到你的广告。</p> -->
      <div class="take-money">
        <div class="take-money-text">升级价格</div>
        <div class="take-money-text" style="color:#ff4848;font-size:0.48rem;">
          <span style="color:#888f99;font-size:0.28rem;">仅需</span>
          <span style="color:#ff4848;font-size:0.3rem;">￥{{takezz_rebate}}</span>
        <!--  <span style="color:#999;font-size:0.3rem;text-decoration:line-through;">原价:￥{{price}}</span> -->
        </div>
      </div>
    </div>
    <div class="vip-one-pay" style="width:94%;height:0.86rem;line-height:0.86rem;font-size:0.34rem;" @click="takeZz">立即支付(￥{{takezz_rebate}})</div>
  </div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/jquery.js"></script>
<script src="../../script/mescroll.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/jsencrypt.js"></script>
<script src="../../script/fastclick.js"></script>

<script>
var vm;
var mescroll;
apiready=function(){
  api.removeLaunchView();
  setBar("statusbar");
  setFont(750);
  startVue();
  $(".public-progress").fadeOut(1000);
  setTimeout(function(){
    $(".public-progress").css({"display":"none"});
  },2000);
}
function startVue(){
  vm = new Vue({
    el:"#app",
    data:{
      gdtt:['100','1000','5000','10000','20000','50000'],
      num:0,
      price:'',
      content:'',
      takezz_rebate:'',
      prices:[],
      userInfo:[],
    },
    created:function(){
      this.getPirce();
      this.getUserInfo();
    },
    methods:{
     getUserInfo:function(){
       api.ajax({
           url: apiUrl+'/api/user/index',
           method: 'post',
           data: {
               values: {
                   token:$api.getStorage('token'),
               },
           }
       },function(ret, err){
     			console.log(JSON.stringify(ret))
           if (ret.code==1) {
             vm.userInfo = ret.data;
           } else {
            vm.userInfo = ret.data;
           }
       });
     },
      //获取升级价格
	  getPirce:function(){
	    api.ajax({
	        url: apiUrl+'/api/index/userLevelInfo',
	        method: 'post',
	        data: {
	  				values: {
	  				    type:4
	  				},
	        }
	    },function(ret, err){
	  			console.log(JSON.stringify(ret))
	        if (ret.code==1) {
	          vm.takezz_rebate = ret.data.price;
	          vm.content = ret.data.description;
	  			   vm.price = ret.data.cost_price;
	        } else {
	          vm.price = '';
	          vm.takezz_rebate = '';
	          vm.content = '';
	        }
	    });
	  },
      //升级站长
      takeZz:function(){
		  console.log(vm.userInfo['type_id']);
        if (vm.userInfo['type_id']=='4') {
          msg('您已是站长，无需再申请');
          return;
        }else if(vm.userInfo['type_id']=='3'){
          msg('你已是合伙人了，无需再次申请');
          return;
        }
        var amount = '';
        // if (vm.userInfo['Identity']=="1") {
        //   if (vm.userInfo['rank']=='0') {
        //     amount = parseInt(vm.takezz_rebate);
        //     var content = '升级站长需支付'+amount+'元是否升级？';
        //   }else if(vm.userInfo['rank']=='1'||vm.userInfo['rank']=='2'||vm.userInfo['rank']=='3'){
        //     var vipprice = parseInt(vm.prices['vipprice']);
        //     amount = parseInt(vm.takezz_rebate) - vipprice;
        //     var content = '折扣原价'+vm.takezz_rebate+',补差价升级站长需支付'+amount+'元是否升级？';
        //   }
        // }
        // if(vm.userInfo['Identity']=='3'){
        //   var partnerprice = parseInt(vm.prices['partnerprice']);
        //   amount = parseInt(vm.takezz_rebate) - partnerprice;
        //   var content = '折扣价'+vm.takezz_rebate+'补差价升级站长需支付'+amount+'元是否升级？';
        // }
        var dialogBox = api.require('dialogBox');
        dialogBox.alert({
            texts: {
                content:'是否确认升级站长',
                leftBtnTitle: '取消',
                rightBtnTitle: '确认'
            },
            styles: {
                bg: '#fff',
                w: 300,
                corner:2,
                content: {
                    color: '#000',
                    size: 14
                },
                left: {
                    marginB: 7,
                    marginL: 20,
                    w: 130,
                    h: 35,
                    corner: 2,
                    bg: '#fff',
                    size: 12
                },
                right: {
                    marginB: 7,
                    marginL: 10,
                    w: 130,
                    h: 35,
                    corner: 2,
                    bg: '#fff',
                    size: 12
                }
            }
        }, function(ret) {
            if (ret.eventType == 'left') {
                var dialogBox = api.require('dialogBox');
                dialogBox.close({
                    dialogName: 'alert'
                });
            }else if(ret.eventType == 'right'){
              var dialogBox = api.require('dialogBox');
              dialogBox.close({
                  dialogName: 'alert'
              });
              api.toast({
                  msg: '订单已提交，请前往支付',
                  duration: 2000,
                  location: 'middle'
              });
              setTimeout(function(){
                api.openWin({
                    name: 'pay',
                    url: '../home/pay.html',
                    pageParam: {
                      // nickname:vm.nickname,
                      release_price:vm.takezz_rebate,
                      types:5,
					  type:8,
					  ad:4,
                      // ad_id:ret.data,
                    }
                });
              },500);
            }
        });

        // api.ajax({
        //     url: apiUrl+'api/home/removeWebmaster',
        //     method: 'post',
        //     data: {
        //         values: {
        //             uid: post_en($api.getStorage('uid')),
        //             price:post_en(vm.price),
        //         },
        //     }
        // },function(ret, err){
        //     if (ret.status) {
        //       api.toast({
        //           msg: ret.msg,
        //           duration: 2000,
        //           location: 'middle'
        //       });
        //       setTimeout(function(){
        //        api.closeWin();
        //       },500);
        //     } else {
        //       api.toast({
        //           msg: ret.msg,
        //           duration: 2000,
        //           location: 'middle'
        //       });
        //     }
        // });

      },
    }
  })
}

</script>
</html>
